package cosplay.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

@Controller
public class LoginController extends MultiActionController {

	@RequestMapping("/login.htm")
	protected ModelAndView handlelogin(HttpServletRequest req,
			HttpServletResponse res) throws Exception {
		// TODO Auto-generated method stub
		if(req.isUserInRole("ROLE_USER")||(req.isUserInRole("USER_ADMIN")))
		{
			res.sendRedirect("welcome.htm");
			return null;
		}
		else
		{
			return new ModelAndView("login");
		}
	}
	@RequestMapping("/welcome.htm")
	protected ModelAndView handlewelcome(HttpServletRequest req,
			HttpServletResponse res) throws Exception {
		// TODO Auto-generated method stub
		return new ModelAndView("welcome");
	}

}
